delete from market_result where MARKET_ID in (select id from event_market where START_DATE < now()) and  not MARKET_ID in(select MARKET from bets)
go
delete from event_market where  START_DATE < now()
go
delete from events where not id in (select EVENT from event_market ) 
go
delete from event_types where not id in (select TYPE_ID from events)
go